//
//  ZqlBottomView.swift
//  ZqlSinaWeiBo
//
//  Created by 赵乾龙 on 16/2/21.
//  Copyright © 2016年 Mr.zhao. All rights reserved.
//

import UIKit
import SnapKit

class ZqlBottomView: UIView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = UIColor(white: 0.8, alpha: 1)
        setUpUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setUpUI(){
        addSubview(repostBtn)
        addSubview(commentBtn)
        addSubview(fezzanBtn)
        
        
        //添加约束
        repostBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(self.snp_left)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
        }
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(repostBtn.snp_right)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
            make.width.equalTo(repostBtn.snp_width)
        }
        fezzanBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)
            make.width.equalTo(commentBtn.snp_width)
            make.right.equalTo(self.snp_right)
        }
        
        let line1 = lineView()
        let line2 = lineView()
        addSubview(line1)
        addSubview(line2)
        line1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(repostBtn.snp_right)
            make.centerY.equalTo(self.snp_centerY)
            make.width.equalTo(0.8)
            make.height.equalTo(self.snp_height).multipliedBy(0.4)
        }
        line2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.centerY.equalTo(self.snp_centerY)
            make.width.equalTo(0.8)
            make.height.equalTo(self.snp_height).multipliedBy(0.4)
        }
        
        //给转发按钮添加点击事件
        repostBtn.addTarget(self, action: "reposBtnDidClick", forControlEvents: .TouchUpInside)
    }
    
    //实现转发按钮的点击事件
    @objc private func reposBtnDidClick(){
        let tempVC = ZqlTempVC()
        navVC()?.pushViewController(tempVC, animated: true)
    }
    
    private func lineView() -> UIView{
        let line = UIView()
        line.backgroundColor = UIColor.lightGrayColor()
        return line
    }
    
    //懒加载视图
    private lazy var repostBtn:UIButton = UIButton(backImageName: nil, title: "转发", textColor: UIColor.lightGrayColor(), imageName: "timeline_icon_retweet")
    
    private lazy var commentBtn:UIButton = UIButton(backImageName: nil, title: "评论", textColor: UIColor.lightGrayColor(), imageName: "timeline_icon_comment")
    
    private lazy var fezzanBtn:UIButton = UIButton(backImageName: nil, title: "赞", textColor: UIColor.lightGrayColor(), imageName: "timeline_icon_unlike")
    
}

    